<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <script>
      // 2. 封装函数，求得传入数组元素的和 [3, 9, 9, 2, 7, 5]
      function getSum(arr) {
        const sum=arr.reduce((sums,item)=>{
          return sums + item
        },0)
        return sum
      }
      let arr2 = [3, 9, 9, 2, 7, 5]
      let sum2 = getSum(arr2)
      console.log(sum2);
  </script>
</body>
</html>